import { get, getBlob } from "@/request";
import Vue from "vue";

export const getAllMusicList = (id) => get("/playList/SongList",{id});

/* 下载 */
export const downloadMusic = (musicUrl, fileName) => {
  getBlob(musicUrl)
    .then((res) => {
      let blob = res;
      let href = URL.createObjectURL(blob);
      let a = document.createElement("a");
      a.href = href;
      a.download = fileName;
      document.body.appendChild(a);
      a.click();
      document.body.removeChild(a);
      Vue.prototype.$message.success(`${fileName}下载成功`);
    })
    .catch((err) => {
      Vue.prototype.$message.$message.error(err);
    });
};
